//一个APP可以拥有多个控制器，而一个控制器专门来控制某个范围视图，负责这个视图的各种渲染操作。
angular.module("orderApp",[])
    .controller("orderctrl",["$http",function($http){
        var oc = this;
        //项目名称
        oc.title = "商品购买订单";

        oc.commodity = [
            {
                userId:3,
                commodityId:1,
                name:"大西瓜",
                image:"#",
                commercialPrice:232.00,
                count:1,
                creatTime:"2015-6-12"},
        ];

        oc.adress = [
            {
                addId:1,
                detailAdd:"乌龙江北戴河南孚西曲镇",
                consignee:"阿朱",
                phone:"12302992933"
            },
            {
                addId:1,
                detailAdd:"乌龙江北戴河南孚西曲镇",
                consignee:"阿朱",
                phone:"12302992933"
            }];


        $http({
            method:"POST",
            url:"/eshop-project/purchase/loadAddress?userId="+oc.commodity[0].userId,
            params:{
            }
        }).then(
            function(resp){
                oc.adress = resp.data;
                console.log("success load adress ok! size="+resp.data.length);
            },
            function(resp){
                console.log("fail to load adress records!");
            }
        );

    }]);

//function getpic(){
//	var file = $(#fileUpload).file[0];
//}

function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
        + " " + date.getHours() + seperator2 + date.getMinutes()
        + seperator2 + date.getSeconds();
    return currentdate;
}
function sayHello(){
    console.log("javascript hello world!");
}

$(document).ready(function () {

})